home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Shell ƒ / graphics dispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  8.4 KB  |  468 lines  |  [TEXT/MMCC]

  1. #include "graphics dispatch.h"
  2. #include "window layer.h"
  3. #include "program globals.h"
  4. #include "edit functions.h"
  5. #include "text twiddling.h"
  6. #include "generic window handlers.h"
  7. #include "about.h"
  8. #include "about MSG.h"
  9. #include "other MSG window.h"
  10. #include "help.h"
  11. #include "jotto main window.h"
  12. #include "jotto note pad.h"
  13.  
  14. enum DispatchError SetupWindowDispatch(short index, WindowPtr theWindow)
  15. {
  16.     SetWindowIndex(theWindow, index);
  17.     SetWindowTE(theWindow, 0L);
  18.     SetWindowVScrollBar(theWindow, 0L);
  19.     SetWindowHScrollBar(theWindow, 0L);
  20.     
  21.     switch (index)
  22.     {
  23.         case kAboutWindow:
  24.             SetupTheAboutWindow(theWindow);
  25.             return kSuccess;
  26.         case kAboutMSGWindow:
  27.             SetupTheAboutMSGWindow(theWindow);
  28.             return kSuccess;
  29.         case kOtherMSGWindow:
  30.             SetupTheOtherMSGWindow(theWindow);
  31.             return kSuccess;
  32.         case kHelpWindow:
  33.             SetupTheHelpWindow(theWindow);
  34.             return kSuccess;
  35.         case kMainWindow:
  36.             SetupTheMainWindow(theWindow);
  37.             return kSuccess;
  38.         case kNotePad:
  39.             SetupTheNotePad(theWindow);
  40.             return kSuccess;
  41.     }
  42.     
  43.     return kFailure;
  44. }
  45.  
  46. enum DispatchError ShutdownWindowDispatch(short index)
  47. {
  48.     switch (index)
  49.     {
  50.         case kAboutWindow:
  51.             ShutDownTheAboutWindow();
  52.             return kSuccess;
  53.         case kAboutMSGWindow:
  54.             ShutDownTheAboutMSGWindow();
  55.             return kSuccess;
  56.         case kHelpWindow:
  57.             ShutDownTheHelpWindow();
  58.             return kSuccess;
  59.         case kMainWindow:
  60.             ShutDownTheMainWindow();
  61.             return kSuccess;
  62.         case kNotePad:
  63.             ShutDownTheNotePad();
  64.             return kSuccess;
  65.     }
  66.     
  67.     return kFailure;
  68. }
  69.  
  70. enum DispatchError OpenWindowDispatch(short index)
  71. {
  72.     WindowPtr        theWindow;
  73.     
  74.     theWindow=GetIndWindowPtr(index);
  75.     
  76.     switch (index)
  77.     {
  78.         case kAboutWindow:
  79.             OpenTheAboutWindow(theWindow);
  80.             return kSuccess;
  81.         case kAboutMSGWindow:
  82.             OpenTheMSGWindow(theWindow);
  83.             return kSuccess;
  84.         case kOtherMSGWindow:
  85.             OpenTheOtherMSGWindow(theWindow);
  86.             return kSuccess;
  87.         case kHelpWindow:
  88.             OpenTheHelpWindow(theWindow);
  89.             return kSuccess;
  90.         case kNotePad:
  91.             OpenTheNotePad(theWindow);
  92.             return kSuccess;
  93.     }
  94.     
  95.     return kFailure;
  96. }
  97.  
  98. enum DispatchError CloseWindowDispatch(short index)
  99. {
  100.     WindowPtr        theWindow;
  101.     
  102.     theWindow=GetIndWindowPtr(index);
  103.     
  104.     switch (index)
  105.     {
  106.         case kMainWindow:
  107.             if (CloseTheMainWindow(theWindow))
  108.                 return kSuccess;
  109.             else
  110.                 return kCancel;
  111.     }
  112.     
  113.     return kFailure;
  114. }
  115.  
  116. enum DispatchError DisposeWindowDispatch(short index)
  117. {
  118.     WindowPtr        theWindow;
  119.     
  120.     theWindow=GetIndWindowPtr(index);
  121.     
  122.     switch (index)
  123.     {
  124.         case kAboutWindow:
  125.             DisposeTheAboutWindow(theWindow);
  126.             return kSuccess;
  127.         case kOtherMSGWindow:
  128.             DisposeTheOtherMSGWindow(theWindow);
  129.             return kSuccess;
  130.         case kHelpWindow:
  131.             DisposeTheHelpWindow(theWindow);
  132.             return kSuccess;
  133.         case kNotePad:
  134.             DisposeTheNotePad(theWindow);
  135.             return kSuccess;
  136.     }
  137.     
  138.     return kFailure;
  139. }
  140.  
  141. enum DispatchError DrawWindowDispatch(short index, short theDepth)
  142. {
  143.     WindowPtr        theWindow;
  144.     
  145.     theWindow=GetIndWindowPtr(index);
  146.     
  147.     switch (index)
  148.     {
  149.         case kAboutMSGWindow:
  150.             DrawTheAboutMSGWindow(theWindow, theDepth);
  151.             return kSuccess;
  152.         case kHelpWindow:
  153.             DrawTheHelpWindow(theWindow, theDepth);
  154.             return kSuccess;
  155.         case kMainWindow:
  156.             DrawTheMainWindow(theWindow, theDepth);
  157.             return kSuccess;
  158.             break;
  159.     }
  160.     
  161.     return kFailure;
  162. }
  163.  
  164. enum DispatchError ChangeDepthDispatch(short index, short newDepth)
  165. {
  166.     WindowPtr        theWindow;
  167.     
  168.     theWindow=GetIndWindowPtr(index);
  169.     
  170.     switch (index)
  171.     {
  172.         case kAboutMSGWindow:
  173.             ChangeDepthTheAboutMSGWindow(theWindow, newDepth);
  174.             return kSuccess;
  175.     }
  176.     
  177.     return kFailure;
  178. }
  179.  
  180. enum DispatchError CopybitsDispatch(short index, WindowPtr offscreenWindow)
  181. {
  182.     WindowPtr        theWindow;
  183.     
  184.     theWindow=GetIndWindowPtr(index);
  185.     
  186.     switch (index)
  187.     {
  188.         case kOtherMSGWindow:
  189.             CopybitsTheOtherMSGWindow(theWindow, offscreenWindow);
  190.             return kSuccess;
  191.         case kMainWindow:
  192.             return (CopybitsTheMainWindow(theWindow, offscreenWindow) ? kSuccess : kFailure);
  193.         case kNotePad:
  194.             CopybitsTheNotePad(theWindow, offscreenWindow);
  195.             return kSuccess;
  196.     }
  197.     
  198.     return kFailure;
  199. }
  200.  
  201. enum DispatchError IdleWindowDispatch(short index, Point mouseLoc)
  202. {
  203.     WindowPtr        theWindow;
  204.     
  205.     theWindow=GetIndWindowPtr(index);
  206.     
  207.     switch (index)
  208.     {
  209.         case kNotePad:
  210.             IdleInNotePad(theWindow, mouseLoc);
  211.             return kPassThrough;
  212.     }
  213.     
  214.     return kFailure;
  215. }
  216.  
  217. enum DispatchError ActivateWindowDispatch(short index)
  218. {
  219.     WindowPtr        theWindow;
  220.     
  221.     theWindow=GetIndWindowPtr(index);
  222.     
  223.     switch (index)
  224.     {
  225.         case kOtherMSGWindow:
  226.             GenericActivate(theWindow);
  227.             ActivateTheOtherMSGWindow(theWindow);
  228.             return kSuccess;
  229.         case kMainWindow:
  230.             ActivateTheMainWindow(theWindow);
  231.             return kSuccess;
  232.         case kNotePad:
  233.             GenericActivate(theWindow);
  234.             ActivateTheNotePad(theWindow);
  235.             return kSuccess;
  236.     }
  237.     
  238.     return kFailure;
  239. }
  240.  
  241. enum DispatchError DeactivateWindowDispatch(short index)
  242. {
  243.     WindowPtr        theWindow;
  244.     
  245.     theWindow=GetIndWindowPtr(index);
  246.     
  247.     switch (index)
  248.     {
  249.         case kOtherMSGWindow:
  250.             GenericDeactivate(theWindow);
  251.             DeactivateTheOtherMSGWindow(theWindow);
  252.             return kSuccess;
  253.         case kMainWindow:
  254.             DeactivateTheMainWindow(theWindow);
  255.             return kSuccess;
  256.         case kNotePad:
  257.             GenericDeactivate(theWindow);
  258.             DeactivateTheNotePad(theWindow);
  259.             return kSuccess;
  260.     }
  261.     
  262.     return kFailure;
  263. }
  264.  
  265. enum DispatchError GrowWindowDispatch(short index)
  266. {
  267.     WindowPtr        theWindow;
  268.     
  269.     theWindow=GetIndWindowPtr(index);
  270.     
  271.     switch (index)
  272.     {
  273.         case kOtherMSGWindow:
  274.             GenericResizeControls(theWindow);
  275.             return kSuccess;
  276.         case kNotePad:
  277.             GenericResizeControls(theWindow);
  278.             return kSuccess;
  279.     }
  280.     
  281.     return kFailure;
  282. }
  283.  
  284. enum DispatchError ZoomWindowDispatch(short index)
  285. {
  286.     WindowPtr        theWindow;
  287.     
  288.     theWindow=GetIndWindowPtr(index);
  289.     
  290.     switch (index)
  291.     {
  292.         case kOtherMSGWindow:
  293.             GenericResizeControls(theWindow);
  294.             return kSuccess;
  295.         case kNotePad:
  296.             GenericResizeControls(theWindow);
  297.             return kSuccess;
  298.     }
  299.     
  300.     return kFailure;
  301. }
  302.  
  303. enum DispatchError GetGrowSizeDispatch(short index, Rect *sizeRect)
  304. {
  305.     WindowPtr        theWindow;
  306.     
  307.     theWindow=GetIndWindowPtr(index);
  308.     
  309.     switch (index)
  310.     {
  311.         case kOtherMSGWindow:
  312.             GenericGetGrowSize(theWindow, sizeRect);
  313.             return kSuccess;
  314.         case kNotePad:
  315.             GenericGetGrowSize(theWindow, sizeRect);
  316.             return kSuccess;
  317.     }
  318.     
  319.     return kFailure;
  320. }
  321.  
  322. enum DispatchError KeyDownDispatch(short index, unsigned char theChar)
  323. {
  324.     WindowPtr        theWindow;
  325.     
  326.     theWindow=GetIndWindowPtr(index);
  327.     
  328.     switch (index)
  329.     {
  330.         case kAboutWindow:
  331.             KeyDownInAboutWindow(theWindow, theChar);
  332.             return kSuccess;
  333.         case kOtherMSGWindow:
  334.             GenericKeyPressedInWindow(theWindow, theChar);
  335.             return kSuccess;
  336.         case kHelpWindow:
  337.             KeyPressedInHelpWindow(theWindow, theChar);
  338.             return kSuccess;
  339.         case kMainWindow:
  340.             KeyPressedInMainWindow(theWindow, theChar);
  341.             return kSuccess;
  342.         case kNotePad:
  343.             if (!GenericKeyPressedInWindow(theWindow, theChar))
  344.                 KeyPressedInNotePad(theWindow, theChar);
  345.             return kSuccess;
  346.     }
  347.     
  348.     return kFailure;
  349. }
  350.  
  351. enum DispatchError MouseDownDispatch(short index, Point thePoint)
  352. {
  353.     WindowPtr        theWindow;
  354.     
  355.     theWindow=GetIndWindowPtr(index);
  356.     
  357.     switch (index)
  358.     {
  359.         case kAboutWindow:
  360.             MouseDownInAboutWindow(theWindow, thePoint);
  361.             return kSuccess;
  362.         case kOtherMSGWindow:
  363.             GenericMouseClickedInWindow(theWindow, thePoint, FALSE);
  364.             return kSuccess;
  365.         case kHelpWindow:
  366.             MouseClickedInHelpWindow(theWindow, thePoint);
  367.             return kSuccess;
  368.         case kMainWindow:
  369.             MouseClickedInMainWindow(theWindow, thePoint);
  370.             return kSuccess;
  371.         case kNotePad:
  372.             GenericMouseClickedInWindow(theWindow, thePoint, TRUE);
  373.             return kSuccess;
  374.     }
  375.     
  376.     return kFailure;
  377. }
  378.  
  379. enum DispatchError UndoDispatch(short index)
  380. {
  381.     switch (index)
  382.     {
  383.     }
  384.     
  385.     return kFailure;
  386. }
  387.  
  388. enum DispatchError CutDispatch(short index)
  389. {
  390.     WindowPtr        theWindow;
  391.     
  392.     theWindow=GetIndWindowPtr(index);
  393.     
  394.     switch (index)
  395.     {
  396.         case kNotePad:
  397.             GenericCut(theWindow);
  398.             return kSuccess;
  399.             break;
  400.     }
  401.     
  402.     return kFailure;
  403. }
  404.  
  405. enum DispatchError CopyDispatch(short index)
  406. {
  407.     WindowPtr        theWindow;
  408.     
  409.     theWindow=GetIndWindowPtr(index);
  410.     
  411.     switch (index)
  412.     {
  413.         case kNotePad:
  414.             GenericCopy(theWindow);
  415.             return kSuccess;
  416.     }
  417.     
  418.     return kFailure;
  419. }
  420.  
  421. enum DispatchError PasteDispatch(short index)
  422. {
  423.     WindowPtr        theWindow;
  424.     
  425.     theWindow=GetIndWindowPtr(index);
  426.     
  427.     switch (index)
  428.     {
  429.         case kNotePad:
  430.             PasteInNotePad(theWindow);
  431.             return kSuccess;
  432.     }
  433.     
  434.     return kFailure;
  435. }
  436.  
  437. enum DispatchError ClearDispatch(short index)
  438. {
  439.     WindowPtr        theWindow;
  440.     
  441.     theWindow=GetIndWindowPtr(index);
  442.     
  443.     switch (index)
  444.     {
  445.         case kNotePad:
  446.             GenericClear(theWindow);
  447.             return kSuccess;
  448.     }
  449.     
  450.     return kFailure;
  451. }
  452.  
  453. enum DispatchError SelectAllDispatch(short index)
  454. {
  455.     WindowPtr        theWindow;
  456.     
  457.     theWindow=GetIndWindowPtr(index);
  458.     
  459.     switch (index)
  460.     {
  461.         case kNotePad:
  462.             GenericSelectAll(theWindow);
  463.             return kSuccess;
  464.     }
  465.     
  466.     return kFailure;
  467. }
  468.